from flask import app, request, jsonify, Flask

from IntelligentDocumentReview.Model.Order import Orders
from IntelligentDocumentReview.Service.reviewService import reply, insertOrder, selectReviewType, replyDetection

app = Flask(__name__)

@app.route('/replyApp', methods=["POST"])
def replyApp():
    ordrId = request.form.get("orderId")
    result = request.form.get("result")

    return jsonify(reply(ordrId, result))

@app.route('/insertOrderApp', methods=["POST"])
def insertOrderApp():

    data = request.json

    o = Orders()
    o.customerId = int(data["customerId"])
    o.customerName = data["customerName"]
    o.nextPersonId = int(data["nextPersonId"])
    o.nextPersonName = data["nextPersonName"]
    o.amountMoney = float(data["amountMoney"])
    o.commodityListStr = data["commodityListStr"]
    o.status = 1

    return jsonify(insertOrder(o))

@app.route('/selectReviewTypeApp', methods=["POST"])
def selectReviewTypeApp():
    ordrId = request.form.get("orderId")
    t = request.form.get("t")

    return jsonify(selectReviewType(t, ordrId))

# @app.route('/replyDetectionApp', methods=["POST"])
# def replyDetectionApp():
#
#     return jsonify(replyDetection())


















